package com.itany.shop.service.impl;

import com.itany.shop.dao.ProductDao;
import com.itany.shop.entity.Product;
import com.itany.shop.exception.DataAccessException;
import com.itany.shop.exception.ServiceException;
import com.itany.shop.factory.ObjectFactory;
import com.itany.shop.service.ProductService;

import java.util.List;

/**
 * Author:shixiaojun@itany.com
 * Date:2022/4/15 14:10
 * Version:1.0-SNAPSHOT
 * Description:
 */
public class ProductServiceImpl implements ProductService {

    private ProductDao productDao = (ProductDao) ObjectFactory.getObject("productDao");

    @Override
    public List<Product> findAll() throws ServiceException {
        try {
            List<Product> products = productDao.selectAll();
            return products;
        } catch (DataAccessException e) {
            e.printStackTrace();
            throw new ServiceException(e.getMessage());
        }
    }
}
